<?php

use Biz\service\Album\AlbumListService;
use Doraemon\tools\Hhzurl;
use Doraemon\tools\IdParse;

class AlbumInfoAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_REGISTER;

    /**
     * @throws \Exception
     */
    public function main()
    {
        $currUid = $this->uid;
        $albumId = trim($this->getRequest()->getPost('album_id', ''));
        $type = trim($this->getRequest()->getPost('type', 1)); //1、只取清单数据 2、取清单以及商品数据

        if (empty($albumId)) {
            throw new Exception('album_id参数缺失');
        }
        $uid = IdParse::getUid($albumId);
        if ($uid != $currUid) {
            throw new Exception('仅可查看自己的清单详情');
        }
        $list = AlbumListService::getInfo($albumId, $type);
        $list['album_link'] = Hhzurl::getAlbumDetailNiceLivingLink($albumId);
        $this->setSuccess($list, self::API_CODE_SUCCES);

    }
}